package wallet

import (
	"gitee.com/xuxinzhi2206/corehub/database/mysql"
	"gorm.io/gorm"
)

// UserBalance 用户余额表
type UserBalance struct {
	gorm.Model
	UserID  int64   `json:"userid" gorm:"column:userid;type:int(11);comment:用户ID"`
	Balance float64 `json:"balance" gorm:"column:balance;type:decimal(10, 2);comment:账户余额"`
}

func (u *UserBalance) FirstBalance(id int64) (*UserBalance, error) {
	return u, mysql.WithMysql(func(db *gorm.DB) error {
		return db.First(u, id).Error
	})
}
